import React, { useEffect } from 'react'
import {useSelector,useDispatch} from "react-redux"
import {asyncGetHitokoto} from "../../store/slices/hitokotoSlice"
export default function Hitokoto() {

    let hitokoto = useSelector(state => state.hitokoto);

    let dispatch = useDispatch();

    useEffect(()=>{
        dispatch(asyncGetHitokoto());
    },[])

    //创建 下一句 方法
    let next = ()=>{
        dispatch(asyncGetHitokoto());
    }

    return (
        <>
            <h1 onClick={next}>我想对你说：{hitokoto.value}</h1>

        </>
    )
}
